<?php
class xml2array
{
    function xml_to_array($xml)
    {
        $array = (array )(simplexml_load_string($xml));
        foreach ($array as $key => $item) {
            $array[$key] = self::struct_to_array((array )$item);
        }
        return $array;
    }
    function struct_to_array($item)
    {
        if (!is_string($item)) {
            $item = (array )$item;
            foreach ($item as $key => $val) {
                $item[$key] = self::struct_to_array($val);
            }
        }
        return $item;
    }
}
?>